package cn.ptu.pmaa.controller;

import cn.ptu.pmaa.entities.ClassRoom;
import cn.ptu.pmaa.service.AdminService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    AdminService adminService;

    //@RequestMapping("/aaa")
    public Object MapTest(){
        HashMap<String,Object> outMap = new HashMap<>();

        //HashMap<String,Object[]> innerMap = new HashMap<>();
        List<HashMap<String,String>> list = new ArrayList<>();
        //String s[] = {"666 ","777"};
        //innerMap.put("a",s);

        HashMap<String,String> inner = new HashMap<>();
        inner.put("a","i l u");
        inner.put("b","i l b");

        HashMap<String,String> inner1 = new HashMap<>();
        inner1.put("a","i l u");
        inner1.put("b","i l b");

        list.add(inner);
        list.add(inner1);



        outMap.put("state",200);
        //outMap.put("innerMap",innerMap);
        outMap.put("data",list);

        return outMap;
    }

    @RequestMapping("/aaa")
    public Object pageH(int pageNum,int pageSize){
        PageHelper.startPage(pageNum,pageSize);
        return adminService.getAllStudentInfo();
    }

    @RequestMapping("/bbb")
    public Object aaa(){
        PageHelper.startPage(1,2);
        List<ClassRoom> classRooms = adminService.getAllClassRoomInfo();
        PageInfo p = new PageInfo<ClassRoom>(classRooms);
        return p;
    }
}
